Load helper functions

Load packages

Preliminaries

## [1] 1.857912e-08

Where did the model fail to run?

There are clear run failure thresholds in the parameters rootd_ft_io and lai_max, and quite strong visual indications that a_wl_io and bio_hum_cn matter.

Histograms of run failures

Histograms of the output at Level 0 (places the model ran and produced output)

Test out some emulators

At the moment, we’ll just keep to the things that we know should work. We’ll use mean NPP as an example

Andy would like to see timeseries of:

cVeg, cSoil and nbp, npp in GtC and GtC/yr.

A clear threshold in the F0 parameter.

It appears that this ensemble is less “clear cut” in having an output that clearly distinguishes between “failed” (or close to it), and “not failed”. Having said that, having an F0 over a threshold seems to kill the carbon cycle, as before.

A DiceKriging emulator for npp

Remove anything with f0 over a threshold.

## 
## optimisation start
## ------------------
## * estimation method   : MLE 
## * optimisation method : BFGS 
## * analytical gradient : used
## * trend model : ~alpha_io + a_wl_io + bio_hum_cn + b_wl_io + dcatch_dlai_io + 
##     dqcrit_io + dz0v_dh_io + f0_io + fd_io + g_area_io + g_root_io + 
##     g_wood_io + gs_nvg_io + hw_sw_io + kaps_roth + knl_io + lai_max_io + 
##     lai_min_io + lma_io + n_inorg_turnover + nmass_io + nr_io + 
##     retran_l_io + retran_r_io + r_grow_io + rootd_ft_io + sigl_io + 
##     sorp + tleaf_of_io + tlow_io + tupp_io + l_vg_soil
## * covariance model : 
##   - type :  matern5_2 
##   - nugget : NO
##   - parameters lower bounds :  1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 1e-10 
##   - parameters upper bounds :  2 2 1.999244 2 1.995574 2 1.998154 1.790352 2 2 2 1.998084 2 2 2 2 2 1.999201 2 1.996693 1.998361 2 2 1.995738 2 1.993455 1.995643 1.998832 2 2 2 2 
##   - best initial criterion value(s) :  -6194.335 
## 
## N = 32, M = 5 machine precision = 2.22045e-16
## At X0, 0 variables are exactly at the bounds
## At iterate     0  f=       6194.3  |proj g|=       1.9656
## At iterate     1  f =       6116.8  |proj g|=        1.3299
## At iterate     2  f =       6104.4  |proj g|=         1.175
## At iterate     3  f =       6092.4  |proj g|=        1.8925
## At iterate     4  f =       6086.6  |proj g|=        1.4084
## At iterate     5  f =       6083.2  |proj g|=        1.2223
## At iterate     6  f =       6078.9  |proj g|=        1.9076
## At iterate     7  f =       6071.7  |proj g|=        1.8935
## At iterate     8  f =       6065.3  |proj g|=        1.6545
## At iterate     9  f =       6063.4  |proj g|=        1.8948
## At iterate    10  f =       6060.2  |proj g|=        1.7062
## At iterate    11  f =       6058.5  |proj g|=        1.5589
## At iterate    12  f =         6057  |proj g|=        1.9083
## At iterate    13  f =       6056.2  |proj g|=        1.5673
## At iterate    14  f =       6056.1  |proj g|=        1.5669
## At iterate    15  f =       6055.8  |proj g|=        1.8997
## At iterate    16  f =       6055.5  |proj g|=        1.9038
## At iterate    17  f =       6054.7  |proj g|=        1.9071
## At iterate    18  f =       6054.4  |proj g|=        1.9018
## At iterate    19  f =       6054.4  |proj g|=        1.8976
## At iterate    20  f =       6054.3  |proj g|=        1.4884
## At iterate    21  f =       6054.3  |proj g|=        1.4838
## At iterate    22  f =       6054.2  |proj g|=        1.4805
## At iterate    23  f =       6054.2  |proj g|=        1.8964
## At iterate    24  f =       6054.1  |proj g|=        1.4762
## At iterate    25  f =       6054.1  |proj g|=        1.4693
## At iterate    26  f =       6053.7  |proj g|=        1.4005
## At iterate    27  f =       6053.5  |proj g|=        1.3903
## At iterate    28  f =       6053.5  |proj g|=        1.8944
## At iterate    29  f =       6053.3  |proj g|=        1.8964
## At iterate    30  f =       6052.7  |proj g|=         1.894
## At iterate    31  f =       6052.4  |proj g|=         1.889
## At iterate    32  f =       6052.3  |proj g|=        1.1748
## At iterate    33  f =       6052.1  |proj g|=        1.3316
## At iterate    34  f =         6052  |proj g|=         1.326
## At iterate    35  f =         6052  |proj g|=        1.8857
## At iterate    36  f =         6052  |proj g|=        1.8865
## At iterate    37  f =         6052  |proj g|=         1.886
## At iterate    38  f =       6051.9  |proj g|=       0.77825
## At iterate    39  f =       6051.9  |proj g|=       0.77259
## At iterate    40  f =       6051.9  |proj g|=        1.2224
## At iterate    41  f =       6051.8  |proj g|=         1.088
## At iterate    42  f =       6051.8  |proj g|=        1.8874
## At iterate    43  f =       6051.8  |proj g|=        1.6253
## At iterate    44  f =       6051.8  |proj g|=       0.89495
## At iterate    45  f =       6051.8  |proj g|=       0.93961
## At iterate    46  f =       6051.8  |proj g|=         0.869
## At iterate    47  f =       6051.7  |proj g|=       0.56662
## At iterate    48  f =       6051.7  |proj g|=       0.59444
## At iterate    49  f =       6051.7  |proj g|=        0.2393
## At iterate    50  f =       6051.7  |proj g|=      0.097373
## At iterate    51  f =       6051.7  |proj g|=      0.082254
## At iterate    52  f =       6051.7  |proj g|=      0.022268
## 
## iterations 52
## function evaluations 59
## segments explored during Cauchy searches 70
## BFGS updates skipped 0
## active bounds at final generalized Cauchy point 25
## norm of the final projected gradient 0.0222682
## final function value 6051.72
## 
## F = 6051.72
## final  value 6051.720329 
## converged

How good are the emulators for each output?

The emulators appear to be at least capturing the broad response for all of the output variables, even if there are different

Compare the previous (twostep algorithm) with straight km output

Heatmaps of sensitivity analysis across a number of variables

Write a function that analyses the quality of emulators

Constraint

Ensemble members that comply with constraints in NPP, NBP, soil and vegetation carbon.

Build an emulator for each output that we have constraints for, and find the input space where those constraints are met.

## [1] 10.063

Pairs plot of input space that is Not Ruled Out Yet when basic constraints are applied to annual data.

Marginal histograms of space that is Not Ruled Out Yet when basic constraints are applied.